//
//  MBDMsgDetailViewModel.swift
//  MasterBoy
//
//  Created by kyson on 2023/11/8.
//

import Foundation


import YYText

class MBDMsgDetailCellModel : MBDCommonCellModel {
    
    var titlelayout : YYTextLayout!
    var subtitlelayout : YYTextLayout!
    var coverURL : String!
    
    var message : MBDMessageModel! {
        didSet {
            let titleAttributeString = NSMutableAttributedString(string: "群审核")
            titleAttributeString.yy_font = UIFont.boldSystemFont(ofSize: 18)
            titleAttributeString.yy_color = UIColor(colorHex: 0x333333)
            
            let titlecontainer = YYTextContainer()
            let titleWidth = CGRectGetWidth(UIScreen.main.bounds) - 15 - 60 - 15 - 15
            titlecontainer.size = CGSizeMake(titleWidth , CGFLOAT_MAX)
            titlecontainer.maximumNumberOfRows = 1
            
            self.titlelayout = YYTextLayout(container: titlecontainer, text: titleAttributeString)
            
            
            let subtitleAttributeString = NSMutableAttributedString(string: self.message.content ?? "")
            subtitleAttributeString.yy_font = UIFont.systemFont(ofSize: 14)
            subtitleAttributeString.yy_lineSpacing = 4
            subtitleAttributeString.yy_color = UIColor(colorHex: 0x333333)
            
            let subtitleContainer = YYTextContainer()
            let subtitleWidth = CGRectGetWidth(UIScreen.main.bounds) - MBDPostCellModel.marginSubtitleLeft - MBDPostCellModel.marginSubtitleRight
            subtitleContainer.size = CGSizeMake(subtitleWidth , CGFLOAT_MAX)
            subtitleContainer.maximumNumberOfRows = 3
            
            self.subtitlelayout = YYTextLayout(container: subtitleContainer, text: subtitleAttributeString)
            
            self.coverURL = MBDPath2URLUtils.filePathPrefix.appending("ico_msg_notify")
        }
        
    }
    
    var cellHeight : CGFloat {
        return 66
    }
    
}

class MBDMsgDetailViewModel : NSObject {
    
    
    var cellModels : Array<Any>?
    
    override init() {
        super.init()
        cellModels = MBDMsgDetailViewModel.defaultCellModels()
        
    }
    
    static func defaultCellModels() -> Array<MBDMsgDetailCellModel>{
        var cellModels = Array<MBDMsgDetailCellModel>()
        
        
        let descs = ["恭喜您发布的群【陕西人在上海】已通过审核","恭喜您发布的群【陕西人在南京】已通过审核","您发布的群【老色批集中营】审核被拒绝，原因：群名或者群描述中涉及敏感词"]
        
        for desc in descs {
            let cellModel1 = MBDMsgDetailCellModel()
            
            let msgModel = MBDMessageModel()
            msgModel.messageId = "1234567"
            msgModel.content = desc
            cellModel1.message = msgModel
            
            cellModels.append(cellModel1)
        }
        
        return cellModels
    }
    
}
